/*
 * mean_test.c
 *
 * Created: 04/04/2012 12:25:23
 *  Author: Dani
 */ 

#include <avr/io.h>
#define F_CPU 8000000
#include <util/delay.h>
#include <avr/interrupt.h>
#include "lcd162.h"
#include "weight_sensor.h"
#include "engine.h"
#include "switch.h"
#include "uart.h"
#include "calibration.h"

void DriversInit();
void Stop();

uint8_t product_number = 0;
uint8_t product_weight = 0;
uint8_t stop = 0;

int main(void)
{
	sei();
	DriversInit();
	
	//CalibrationEnter();

	while (1)
	{	
		ShowWeight();
	}
}

void DriversInit()
{
	EngineInit();
	LCDInit();
	SwitchInit();
	WeightSensorInit();	
	UARTInit(9600,8);
}

void Stop()
{
	if (stop)
	{
		EngineControl(ENGINE_ALL,SPEED_MAX);
		stop = 0;	
		LCDClear();	
	}
	else
	{
		EngineControl(ENGINE_ALL,0);
		stop = 1;	
		LCDGotoXY(9,1);
		LCDDispString("Stop");
	}
	
}

ISR(S1)
{
	Stop();
}

ISR (S2)
{
	EngineControl(ENGINE5,SPEED_MAX);
}






